﻿using System;
using System.IO;

namespace Abstract2ion
{
	public class FileItem : IFileItem
	{
		private readonly FileInfo _fileInfo;

		public FileItem(string path)
		{
			_fileInfo = new FileInfo(path);
		}

		public FileItem(FileInfo fileInfo)
		{
			if (fileInfo == null)
			{
				throw new ArgumentNullException("fileInfo");
			}

			_fileInfo = fileInfo;
		}

		public string Name
		{
			get { return _fileInfo.Name; }
		}

		public string FullName
		{
			get { return _fileInfo.FullName; }
		}
		public string Extension
		{
			get { return _fileInfo.Extension; }
		}

		public bool Exists
		{
			get { return _fileInfo.Exists; }
		}

		public byte[] ReadAllBytes()
		{
			return Exists ? File.ReadAllBytes(_fileInfo.FullName) : null;
		}
	}
}